package com.cqc.zhbjcqc.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesUtil {
	private static SharedPreferences sharedPreferences;

    public static  String isFirst = "isFirst";
	//存储String
	public static void saveString(Context context,String key,String value){
		if(sharedPreferences == null){
			sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		}
		sharedPreferences.edit().putString(key, value).commit();
	}
	//读取String
	public static String getString(Context context,String key,String defValue){
		if(sharedPreferences == null){
			sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
		}
		return sharedPreferences.getString(key, defValue);
	}

    //存储Boolean
    public static void saveBoolean(Context context,String key,boolean value){
        if(sharedPreferences == null){
            sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        sharedPreferences.edit().putBoolean(key, value).commit();
    }
    //读取Boolean
    public static boolean getBoolean(Context context,String key,boolean defValue){
        if(sharedPreferences == null){
            sharedPreferences = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        return sharedPreferences.getBoolean(key, defValue);
    }
}
